package com.hc.res;

import com.hc.common.utils.JsonUtil;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @author hc
 * @date 2022/1/5 16:20
 */
@Getter
@Setter
@ToString
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class Specs {
    /**
     * 规格名称
     */
    @ApiModelProperty(value = "规格名称")
    private String name;
    /**
     * 规格参数
     */
    @ApiModelProperty(value = "规格参数")
    private List<Map<String, String>> value;

    public static void main(String[] args) {
        Map<String, String> map11 = Map.of("id", 1 + "", "img", "a.jpg", "info", "升级加厚粉色");
        Map<String, String> map12 = Map.of("id", 2 + "", "img", "b.jpg", "info", "加厚黄色");
        Map<String, String> map13 = Map.of("id", 3 + "", "img", "c.jpg", "info", "加厚紫色");
        Map<String, String> map14 = Map.of("id", 4 + "", "img", "d.jpg", "info", "普通黑色");

        Specs color = Specs.builder()
                .name("选择颜色")
                .value(List.of(map11, map12, map13, map14))
                .build();

        Map<String, String> map21 = Map.of("id", 1 + "", "info", "R5-5800H 16G 128G 2K");
        Map<String, String> map22 = Map.of("id", 2 + "", "info", "R5-2800H 8G 512G 4K");
        Map<String, String> map23 = Map.of("id", 3 + "", "info", "R5-3800H 32G 256G 8K");
        Map<String, String> map24 = Map.of("id", 4 + "", "info", "R5-6800H 64G 1024G 16K");
        Specs version = Specs.builder()
                .name("选择版本")
                .value(List.of(map21, map22, map23, map24))
                .build();

        List<Specs> list = new ArrayList<>();
        list.add(color);
        list.add(version);

        System.out.println(JsonUtil.obj2String(list));
    }


}
